﻿Imports System.Data
Imports ADOEntityKYC
Partial Class KYC_IndividualSectionC
    Inherits Web.UI.BasePage

#Region " Variable Gobal "
    Dim ds As DataSet
    Dim TypeKYC As Integer = 0
    Dim CustSeq As Integer = 0
    Dim KYCEntity As KYCEntities = New KYCEntities
    Dim clsSessionMenuRight As clsSessionMenuRight = New clsSessionMenuRight
    Dim clsCheckLanguage As clsCheckLanguage
    Dim clsMoney As clsMoney
    Dim strMsg As String = ""
    Dim condition As Boolean = True
    Dim convertDate As clsDateFormat

#End Region

#Region "Even Page"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            TypeKYC = Request.QueryString("TypeKYC") 'ประเภทการทำงาน
            CustSeq = Request.QueryString("CUSTSEQ") 'รหัสลูกค้า

            ds = Session("ds")
            clsSessionMenuRight = Session("clsMenuRight")

            If Not TypeKYC = 4 Then
                btnCancel.Attributes.Add("onclick", "return confirm('" + String.Format(Resources.resMsgKYC.msgCancle) + "')")
                btnBack.Attributes.Add("onclick", "return confirm('" + String.Format(Resources.resMsgKYC.msgKYCNext) + "')")
            End If

            If Not IsPostBack Then
                chkIsLogin()
                CreateControlMP()
                BindingDataCBS()

                If Request.QueryString("KYC") = 4 Then
                    BindingDataKYC(1)
                    BindingDataKYCLoan()
                    BindingDataKYCPN()
                Else
                    BindingDataKYC(CInt(Request.QueryString("KYC")))
                End If

                loadDataToDropDown()
                EnableKYC()
                VisbleKYC()

                If Request.QueryString("CDD") = 1 Then
                    lblRiskLevel.ForeColor = Drawing.Color.Green
                Else
                    If Request.QueryString("CDD") = 2 Then
                        lblRiskLevel.ForeColor = Drawing.Color.Orange
                    Else
                        lblRiskLevel.ForeColor = Drawing.Color.Red
                    End If
                End If
            End If

        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Session("ds") = ds
    End Sub

#End Region

#Region "SetForm"

    Sub CreateControlMP()
        Dim img As Image = CType(Master.FindControl("imgHead"), Image)
        img.ImageUrl = "~/img/Individual.jpg"

        Dim page As Label = CType(Master.FindControl("lblPage"), Label)
        page.Text = "ข้อมูล KYC (Section C)"
    End Sub

    Sub VisbleKYC()
        If Request.QueryString("KYC") = 1 Then
            PanelDeposit.Visible = True
            PanelLoan.Visible = False
            PanelPN.Visible = False
        ElseIf Request.QueryString("KYC") = 2 Then
            PanelDeposit.Visible = True
            PanelLoan.Visible = False
            PanelPN.Visible = False
        ElseIf Request.QueryString("KYC") = 3 Then
            PanelDeposit.Visible = True
            PanelLoan.Visible = False
            PanelPN.Visible = False
        Else
            PanelDeposit.Visible = True
            PanelLoan.Visible = True
            PanelPN.Visible = True

            btnEdit.Visible = False
            btnFinish.Visible = False
        End If
    End Sub

    Sub EnableKYC()
        If TypeKYC = 4 Then
            PanelDeposit.Enabled = False
            PanelLoan.Enabled = False
            PanelPN.Enabled = False
            Panel1.Enabled = False

            btnEdit.Visible = True
            btnFinish.Visible = False

            txtDApproveDate.Visible = False
            txtApproveDate.Visible = True

        Else
            PanelDeposit.Enabled = True
            PanelLoan.Enabled = True
            PanelPN.Enabled = True

            btnEdit.Visible = False

            txtDApproveDate.Visible = True
            txtApproveDate.Visible = False

        End If
    End Sub

#End Region

#Region "Event Button"

    Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBack.Click
        Try
            Response.Redirect("IndividualKYC.aspx?KYC=" & Request.QueryString("KYC") & "&TypeKYC=" & TypeKYC & "&CUSTSEQ=" & CustSeq & "&CDD=3")
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

    Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Try
            Response.Redirect("IndividualSearch.aspx?KYC=" & Request.QueryString("KYC") & "&CustSeq=" & CustSeq & "")
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

    Protected Sub btnFinish_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFinish.Click
        Try
            If TypeKYC = 4 Or Request.QueryString("KYC") = 4 Then
                Response.Redirect("IndividualSearch.aspx?KYC=" & Request.QueryString("KYC") & "&CustSeq=" & CustSeq & "")
            Else

                Call txtDValue_TextChanged(sender, e)
                If condition = False Then
                    condition = True
                    Exit Sub
                End If

                If checkBeforeSave() = True Then

                    If checkApprove() = False Then
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" & strMsg & "')", True)
                        Exit Sub
                    End If

                    KYCEntity = New KYCEntities
                    KYCEntity.Connection.Open()
                    Using transaction As System.Data.Common.DbTransaction = KYCEntity.Connection.BeginTransaction()
                        Try
                            saveCustomer()
                            saveUpdateKYC()
                            transaction.Commit()
                        Catch ex As Exception
                            transaction.Rollback()
                            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('Error : " & ex.ToString & " Error message : " & ex.Message & "')", True)
                        End Try
                    End Using

                    KYCEntity.SaveChanges()
                    KYCEntity = Nothing

                    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "message", _
                               "alert('" + Resources.resMsgKYC.msgSave + "');location.href = 'IndividualSectionC.aspx?KYC=" & Request.QueryString("KYC") & "&TypeKYC=4&CUSTSEQ=" & CustSeq & "&CDD=" & Request.QueryString("CDD") & "';", True)

                Else
                    If Not strMsg = "" Then
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" & strMsg & "')", True)
                    End If
                End If
            End If
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

    Protected Sub btnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Try
            Response.Redirect("IndividualSectionC.aspx?KYC=" & Request.QueryString("KYC") & "&TypeKYC=3&CUSTSEQ=" & Request.QueryString("CUSTSEQ") & "&CDD=" & Request.QueryString("CDD") & "")
        Catch ex As Exception
            ScriptManager.RegisterStartupScript(UpdatePanel1, _
                                                            UpdatePanel1.GetType(), _
                                                            "clientScript", _
                                                            "alert('" + ex.Message.Replace("'", "") + "')", _
                                                            True)
        End Try
    End Sub

#End Region

#Region "Function"

    Private Sub loadDataToDropDown()
        Try
            Dim clsDropDown As New clsMasterDropDown

            clsDropDown.setApproveToDdl(ddlDApprove)
            If Request.QueryString("KYC") = 4 Then
                clsDropDown.setApproveToDdl(ddlLApprove)
                clsDropDown.setApproveToDdl(ddlPApprove)
            End If

            clsDropDown = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BindingDataCBS() 'ข้อมูลพื้นฐานลูกค้า 
        Try
            Dim qryA = (From cust In KYCEntity.MCUSTOMER _
                                    Where cust.CUSTSEQ = CustSeq
                                    Select cust).ToList

            If qryA(0).CUSTCODE = Nothing Then
                lblCustCode.Text = "เลขประจำตัวลูกค้า : -"
            Else
                lblCustCode.Text = "เลขประจำตัวลูกค้า : " + qryA(0).CUSTCODE.ToString
            End If

            Dim riskLevel As String = ""
            riskLevel = "ระดับความเสี่ยงลูกค้า : " + CStr(qryA(0).AMLCDD)

            If qryA(0).AMLCDD > 1 Then
                riskLevel += " (เหตุผล : " + CStr(qryA(0).AMLREASON) + ")"
            End If

            lblRiskLevel.Text = riskLevel

            qryA = Nothing
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Function checkBeforeSave() As Boolean
        Try
            Dim result As Boolean = True

            If chkDAsset6.Checked = True Then
                If txtDAssetOther.Text = "" Then
                    result = False
                    Image1.ImageUrl = "~/img/icon/cancel.png"
                    strMsg = strMsg + Resources.resMsgAlertKYC.NotOther + "\n"
                Else
                    Image1.ImageUrl = "~/img/icon/accept.png"
                End If
            End If

            'If ddlDApprove.SelectedIndex = 0 Then
            '    result = False
            '    Image3.ImageUrl = "~/img/icon/cancel.png"
            '    strMsg = strMsg + Resources.resMsgAlertKYC.NotStatusApprove + "\n"
            'ElseIf ddlDApprove.SelectedValue = 1 Then
            '    result = False
            '    Image3.ImageUrl = "~/img/icon/cancel.png"
            '    strMsg = strMsg + Resources.resMsgAlertKYC.NotStatusApprove + "\n"
            'ElseIf ddlDApprove.SelectedValue = 2 Or ddlDApprove.SelectedValue = 3 Then
            '    'If txtDApprove.Text.Trim = "" Then
            '    '    result = False
            '    '    Image4.ImageUrl = "~/img/icon/cancel.png"
            '    '    strMsg = strMsg + Resources.resMsgAlertKYC.NotApproveName + "\n"
            '    'Else
            '    '    Image4.ImageUrl = "~/img/icon/accept.png"
            '    'End If

            '    If txtDApproveNo.Text.Trim = "" Then
            '        result = False
            '        Image5.ImageUrl = "~/img/icon/cancel.png"
            '        strMsg = strMsg + Resources.resMsgAlertKYC.NotApproveNo + "\n"
            '    Else
            '        Image5.ImageUrl = "~/img/icon/accept.png"
            '    End If

            '    If txtDApproveDate.Text = "" Then
            '        result = False
            '        Image6.ImageUrl = "~/img/icon/cancel.png"
            '        strMsg = strMsg + Resources.resMsgAlertKYC.NotApproveDate + "\n"
            '    Else
            '        Image6.ImageUrl = "~/img/icon/accept.png"
            '    End If

            'Else
            '    Image3.ImageUrl = "~/img/icon/accept.png"
            'End If

            If result = False Then
                statusValidation()
            End If

            Return result
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Sub statusValidation()
        Try
            Image1.Visible = True
            Image2.Visible = True
            Image3.Visible = True
            'Image4.Visible = True
            Image5.Visible = True
            Image6.Visible = True
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BindingDataKYC(ByVal type As Integer)
        Try
            If type = 1 Then
                type = 1
                lblName.Text = "(เงินฝาก)"
            ElseIf type = 2 Then
                type = 3
                lblName.Text = "(สินเชื่อ)"
            ElseIf type = 3 Then
                type = 5
                lblName.Text = "(ใบรับเงินฝากประจำ)"
            End If

            Dim qryKYC = (From kyc In KYCEntity.RKYC
                          Where kyc.CUSTSEQ = CustSeq And kyc.ANSWERTYPE = type
                          Select kyc).ToList

            If Not qryKYC.Count = 0 Then

                If qryKYC(0).ASSET1 = 0 Then
                    chkDAsset1.Checked = True
                End If
                If qryKYC(0).ASSET2 = 0 Then
                    chkDAsset2.Checked = True
                End If
                If qryKYC(0).ASSET3 = 0 Then
                    chkDAsset3.Checked = True
                End If
                If qryKYC(0).ASSET4 = 0 Then
                    chkDAsset4.Checked = True
                End If
                If qryKYC(0).ASSET5 = 0 Then
                    chkDAsset5.Checked = True
                End If
                If qryKYC(0).ASSET6 = 0 Then
                    chkDAsset6.Checked = True
                    txtDAssetOther.Text = qryKYC(0).ASSETOTHER
                End If

                If Not qryKYC(0).APPROVECODE Is Nothing Then
                    ddlDApprove.SelectedValue = qryKYC(0).APPROVECODE
                End If
                'txtDApprove.Text = qryKYC(0).APPROVENAME
                txtDApproveNo.Text = qryKYC(0).APPROVENO

                convertDate = New clsDateFormat
                If qryKYC(0).APPROVEDATE Is Nothing Then
                    txtDApproveDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, Now.Date)
                ElseIf Not qryKYC(0).APPROVEDATE Is Nothing Then
                    txtDApproveDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, qryKYC(0).APPROVEDATE)
                    txtApproveDate.Text = convertDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, qryKYC(0).APPROVEDATE)
                End If
                convertDate = Nothing

                If Not qryKYC(0).TOTALASSET Is Nothing Then
                    clsMoney = New clsMoney
                    txtDValue.Text = clsMoney.insertComma(qryKYC(0).TOTALASSET)
                    clsMoney = Nothing

                End If

            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BindingDataKYCLoan()
        Try
            Dim qryKYC = (From kyc In KYCEntity.RKYC
                          Where kyc.CUSTSEQ = CustSeq And kyc.ANSWERTYPE = 3
                          Select kyc).ToList

            If Not qryKYC.Count = 0 Then

                If qryKYC(0).ASSET1 = 0 Then
                    chkLAsset1.Checked = True
                End If
                If qryKYC(0).ASSET2 = 0 Then
                    chkLAsset2.Checked = True
                End If
                If qryKYC(0).ASSET3 = 0 Then
                    chkLAsset3.Checked = True
                End If
                If qryKYC(0).ASSET4 = 0 Then
                    chkLAsset4.Checked = True
                End If
                If qryKYC(0).ASSET5 = 0 Then
                    chkLAsset5.Checked = True
                End If
                If qryKYC(0).ASSET6 = 0 Then
                    chkLAsset6.Checked = True
                    txtLAssetOther.Text = qryKYC(0).ASSETOTHER
                End If

                If Not qryKYC(0).APPROVECODE Is Nothing Then
                    ddlLApprove.SelectedValue = qryKYC(0).APPROVECODE
                End If
                'txtLApprove.Text = qryKYC(0).APPROVENAME
                txtLApproveNo.Text = qryKYC(0).APPROVENO
                If Not qryKYC(0).APPROVEDATE Is Nothing Then
                    txtLApproveDate.Text = qryKYC(0).APPROVEDATE
                End If
                If Not qryKYC(0).TOTALASSET Is Nothing Then
                    clsMoney = New clsMoney
                    txtLValue.Text = clsMoney.insertComma(qryKYC(0).TOTALASSET)
                    clsMoney = Nothing
                End If

            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub BindingDataKYCPN()
        Try
            Dim qryKYC = (From kyc In KYCEntity.RKYC
                          Where kyc.CUSTSEQ = CustSeq And kyc.ANSWERTYPE = 5
                          Select kyc).ToList

            If Not qryKYC.Count = 0 Then

                If qryKYC(0).ASSET1 = 0 Then
                    chkPAsset1.Checked = True
                End If
                If qryKYC(0).ASSET2 = 0 Then
                    chkPAsset2.Checked = True
                End If
                If qryKYC(0).ASSET3 = 0 Then
                    chkPAsset3.Checked = True
                End If
                If qryKYC(0).ASSET4 = 0 Then
                    chkPAsset4.Checked = True
                End If
                If qryKYC(0).ASSET5 = 0 Then
                    chkPAsset5.Checked = True
                End If
                If qryKYC(0).ASSET6 = 0 Then
                    chkPAsset6.Checked = True
                    txtPAssetOther.Text = qryKYC(0).ASSETOTHER
                End If

                If Not qryKYC(0).APPROVECODE Is Nothing Then
                    ddlPApprove.SelectedValue = qryKYC(0).APPROVECODE
                End If
                'txtPApprove.Text = qryKYC(0).APPROVENAME
                txtPApproveNo.Text = qryKYC(0).APPROVENO
                If Not qryKYC(0).APPROVEDATE Is Nothing Then
                    txtPApproveDate.Text = qryKYC(0).APPROVEDATE
                End If
                If Not qryKYC(0).TOTALASSET Is Nothing Then
                    clsMoney = New clsMoney
                    txtPValue.Text = clsMoney.insertComma(qryKYC(0).TOTALASSET)
                    clsMoney = Nothing
                End If

            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub saveCustomer()
        Try
            Dim updateCust = (From Cust In KYCEntity.MCUSTOMER
                            Where Cust.CUSTSEQ = CustSeq
                            Select Cust).First()

            If ddlDApprove.SelectedValue = 1 Then
                If Request.QueryString("KYC") = 1 Then
                    updateCust.DEPUPDATE = "D"
                    updateCust.DEPD = "N"
                ElseIf Request.QueryString("KYC") = 2 Then
                    updateCust.DEPUPDATE = "L"
                    updateCust.DEPL = "N"
                ElseIf Request.QueryString("KYC") = 3 Then
                    updateCust.DEPUPDATE = "P"
                    updateCust.DEPP = "N"
                End If
            Else
                If Request.QueryString("KYC") = 1 Then
                    updateCust.DEPUPDATE = "D"
                    updateCust.DEPD = "Y"
                ElseIf Request.QueryString("KYC") = 2 Then
                    updateCust.DEPUPDATE = "L"
                    updateCust.DEPL = "Y"
                ElseIf Request.QueryString("KYC") = 3 Then
                    updateCust.DEPUPDATE = "P"
                    updateCust.DEPP = "Y"
                End If
            End If

        Catch ex As Exception
            Throw ex
        End Try

        'updateCust.UPDATEBY = clsSessionMenuRight.getUserName
        'updateCust.UPDATEDATE = Now.ToShortDateString
    End Sub

    Private Sub saveUpdateKYC()
        Try
            Dim type As Integer = Request.QueryString("KYC")

            If type = 1 Then
                type = 1
                saveUpdateKYCData(type)
            ElseIf type = 2 Then
                type = 3
                saveUpdateKYCData(type)
            ElseIf type = 3 Then
                type = 5
                saveUpdateKYCData(type)
            Else
                'For i As Integer = 0 To 4
                '    type = i + 1
                '    saveUpdateKYCData(type)
                '    i = type
                'Next
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub saveUpdateKYCData(ByVal type As Integer)
        Try
            Dim updateKYC = (From k In KYCEntity.RKYC
                          Where k.CUSTSEQ = CustSeq And k.ANSWERTYPE = type
                          Select k).First()

            If chkDAsset1.Checked = True Then
                updateKYC.ASSET1 = 0
            Else
                updateKYC.ASSET1 = 1
            End If
            If chkDAsset2.Checked = True Then
                updateKYC.ASSET2 = 0
            Else
                updateKYC.ASSET2 = 1
            End If
            If chkDAsset3.Checked = True Then
                updateKYC.ASSET3 = 0
            Else
                updateKYC.ASSET3 = 1
            End If
            If chkDAsset4.Checked = True Then
                updateKYC.ASSET4 = 0
            Else
                updateKYC.ASSET4 = 1
            End If
            If chkDAsset5.Checked = True Then
                updateKYC.ASSET5 = 0
            Else
                updateKYC.ASSET5 = 1
            End If
            If chkDAsset6.Checked = True Then
                updateKYC.ASSET6 = 0
                updateKYC.ASSETOTHER = txtDAssetOther.Text
            Else
                updateKYC.ASSET6 = 1
            End If

            If txtDValue.Text = "" Then
                updateKYC.TOTALASSET = Nothing
            Else
                clsMoney = New clsMoney
                updateKYC.TOTALASSET = clsMoney.deleteComma(txtDValue.Text.Trim)
                clsMoney = Nothing
            End If


            updateKYC.APPROVECODE = ddlDApprove.SelectedValue
            updateKYC.APPROVENAME = txtDApproveNo.Text.Trim
            updateKYC.APPROVENO = txtDApproveNo.Text.Trim
            If txtDApproveDate.Text = "" Then
                updateKYC.APPROVEDATE = Nothing
            Else
                Dim clsFormatDate As clsDateFormat = New clsDateFormat
                updateKYC.APPROVEDATE = clsFormatDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.En, txtDApproveDate.Text)
                clsFormatDate = Nothing
            End If

            If ddlDApprove.SelectedValue = 1 Then
                updateKYC.KYCCOMPLETE = "N"
            Else
                updateKYC.KYCCOMPLETE = "Y" 'ถือว่าทำ KYC สมบูรณ์แล้ว
            End If

            updateKYC.UPDATEBY = clsSessionMenuRight.getUserName
            updateKYC.UPDATEDATE = Now.ToShortDateString

            If Request.QueryString("KYC") = 1 Then
                updateKYC.DEPUPDATE = "D"
            ElseIf Request.QueryString("KYC") = 2 Then
                updateKYC.DEPUPDATE = "L"
            ElseIf Request.QueryString("KYC") = 3 Then
                updateKYC.DEPUPDATE = "P"
            End If

            updateKYC.BRANCHCODE = clsSessionMenuRight.getBranchCode
            updateKYC.ZONECODE = clsSessionMenuRight.getZoneCode
            updateKYC.DEPTCODE = clsSessionMenuRight.getDeptCode
            updateKYC.ALLCODERIGHT = clsSessionMenuRight.getAllCodeRight
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Function checkApprove() As Boolean
        Try
            Dim result As Boolean = True

            If ddlDApprove.SelectedIndex = 0 Then
                result = False
                Image3.ImageUrl = "~/img/icon/cancel.png"
                Image3.Visible = True
                strMsg = strMsg + Resources.resMsgAlertKYC.NotStatusApprove + "\n"
            ElseIf ddlDApprove.SelectedValue = 2 Or ddlDApprove.SelectedValue = 3 Then
                Image5.ImageUrl = "~/img/icon/accept.png"
                If txtDApproveNo.Text.Trim = "" Then
                    result = False
                    Image5.ImageUrl = "~/img/icon/cancel.png"
                    strMsg = strMsg + Resources.resMsgAlertKYC.NotApproveNo + "\n"
                Else
                    Dim clsCheckApprove As clsCheckApprove = New clsCheckApprove
                    Dim strApp As String = clsCheckApprove.checkRightApprove(txtDApproveNo.Text, clsSessionMenuRight.getUserName, clsSessionMenuRight.getRoleGroup, clsSessionMenuRight.getBranchCode, clsSessionMenuRight.getZoneCode, clsSessionMenuRight.getDeptCode, "")

                    If strApp = "" Then
                        Image5.ImageUrl = "~/img/icon/accept.png"
                    Else
                        result = False
                        Image5.ImageUrl = "~/img/icon/cancel.png"
                        strMsg = strMsg + strApp + "\n"
                    End If
                End If
                If txtDApproveDate.Text = "" Then
                    result = False
                    Image6.ImageUrl = "~/img/icon/cancel.png"
                    strMsg = strMsg + Resources.resMsgAlertKYC.NotApproveDate + "\n"
                Else
                    Image6.ImageUrl = "~/img/icon/accept.png"
                End If

                Image3.Visible = True
                Image5.Visible = True
                Image6.Visible = True

            End If

            Return result
        Catch ex As Exception
            Throw ex
        End Try
    End Function

#End Region

    Protected Sub txtDValue_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDValue.TextChanged
        Try
            If Not txtDValue.Text = "" Then
                clsMoney = New clsMoney
                If clsMoney.insertComma(txtDValue.Text.Trim) = True Then
                    txtDValue.Text = clsMoney.insertComma(txtDValue.Text.Trim)
                    Image2.ImageUrl = "~/img/icon/accept.png"
                    Image2.Visible = True
                End If
                clsMoney = Nothing
            End If
        Catch ex As Exception
            condition = False
            Image2.ImageUrl = "~/img/icon/cancel.png"
            Image2.Visible = True
            ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "clientScript", "alert('" & clsMoney.getStrMsg & "')", True)

        End Try
    End Sub

   
    Protected Sub ddlDApprove_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDApprove.SelectedIndexChanged
        If ddlDApprove.SelectedIndex = 0 Then
            'txtApprove.Enabled = False
            txtDApproveNo.Enabled = False
            'txtApprove.Text = ""
            txtDApproveNo.Text = ""
        Else
            If ddlDApprove.SelectedValue = 1 Then
                'txtApprove.Enabled = False
                txtDApproveNo.Enabled = False
                'txtApprove.Text = ""
                txtDApproveNo.Text = ""
            Else
                'txtApprove.Enabled = True
                txtDApproveNo.Enabled = True
            End If
        End If
    End Sub
End Class
